/*
 * Copyright (c) 2024 Termony Co., Ltd. All rights reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef HDF_AMP_VUART_H
#define HDF_AMP_VUART_H

#include "hdf_device_desc.h"
#include "osal_mutex.h"
#include "osal_timer.h"
#include "uart_core.h"
#include "hdf_dlist.h"
#include "hdf_sbuf.h"

#include "openamp.h"

#ifdef __cplusplus
extern "C" {
#endif

struct VuartDataItem {
    struct DListHead list;
    uint32_t size;
    uint32_t used;
};

struct VuartCb {
    struct UartHost *host;
    bool initFlag;

    struct HdfSBuf *data;
    struct DListHead recv;

    struct OsalMutex rxMux;
    struct OsalMutex txMux;

    struct {
        const char *name;
    } cfg;
};

int32_t HDF_VuartIsrRegister(struct VuartCb *vuartCb);
int32_t HDF_VuartIsrUnregister(struct VuartCb *vuartCb);

int32_t HDF_VuartInit(struct VuartCb *vuartCb);
int32_t HDF_VuartDeinit(struct VuartCb *vuartCb);

int32_t HDF_VuartServiceRequest(struct VuartCb *vuartCb, uint32_t event, uint32_t size);

int32_t HDF_VuartHostParser(struct UartHost *host, struct HdfDeviceObject *device);

#ifdef __cplusplus
}
#endif

#endif /* HDF_AMP_VUART_H */